#include <iostream>
using namespace std;


int targetDigit = 2;

int GetTotalDigit(int num, int target);


int main() {
    int L, R;
    cin >> L >> R;
    // 1 <= L <= R <= 10000
    if(L < 0 || R < 0 || (R < L)){
        std::cerr << "Input Invalid\n";
    }
    std::cout << GetTotalDigit(R,targetDigit) - GetTotalDigit(L - 1, targetDigit) << "\n";
}

int GetTotalDigit(int num, const int target){
    if(num < 0) return -1;
    int factor = 1;
    int ret = 0;
    while(num / factor){
        int high = num / (factor * 10);
        int cur  = (num / factor) % 10;
        int low  = num % factor;

        if(cur < 2){
            ret += high * factor;
        }
        else if(cur == 2){
            ret += high * factor + low + 1;
        }
        else  { //cur > 2
            ret += (high + 1) * factor;
        }
        factor *= 10;
    }
    return ret;
}